/**
 * status 0 待发货 1配送中 2派送中 3已签收
 * 
 * 
 */
const waybill_info = {
    status:"0",
    name:"百世快递",
    num:'124546878785'
};

const details_info = [
    { info: '[已签收,签收人是某某某]', date: '1507969249' },
    { info: '九江市[瑞昌],[**]正在派件', date: '1507969249' },
    { info: '到九江市 [瑞昌]', date: '1507969249' },
    { info: '南昌市 [南昌转润中心],正发往[瑞昌]', date: '1507969249' },
];

// pages/mine/logistics/logistics.js
Page({
    /**页面的初始数据*/
    data: {
        waybill_info:{},                // 运单信息
        details_info:{}                 // 物流详细信息
    },

    /** 数据初始化 */
    onLoad: function (options) {
        // 模拟请求数据
        const that = this;
        setTimeout(_=>{
            that.setData({
                waybill_info: waybill_info
            });
        },1000);

        this.Init(waybill_info, details_info)
        
    },

    /** 数据初始化处理 */
    Init: function (waybill_info, details_info){
        // 运单信息
        switch (waybill_info.status){
            case '0':
                waybill_info.status = '待发货';
                break;
            case '1':
                waybill_info.status = '配送中';
                break;
            case '2':
                waybill_info.status = '派送中';
                break;
            case '3':
                waybill_info.status = '已签收';
                break;
        };

        // 处理物流详细信息
        details_info.map((item)=>{
            item.date = this.Format(item.date);
        });
        
        this.setData({
            waybill_info: waybill_info,
            details_info: details_info
        })

    },
    /** 时间戳处理 */
    Format:function(time){
        let date = new Date(parseInt(time) * 1000);
        let ymd = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
        let hms = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
        return ymd + " " + hms;
    },   
    /** 页面加载 */
    onShow:function(){

    },
    /** 页面跳转*/
    navigateTo:function(){
        wx.navigateTo({
            url: '',
        })
    },

    onShareAppMessage: function () {
    
    }
})